import {
	createRouter,
	createWebHashHistory
} from 'vue-router'
import login from '../views/login/login.vue'
import register from '../views/register/register.vue'
import home from '../views/homepage/home.vue'
import douyu from '../views/douyu/DouYuOne.vue'
/* 测试文件上传 */
import upload from '../components/upload/Upload.vue'
const routes = [{
		path: '/',
		name: 'home',
		component: home
	},
	{
		path: '/login',
		name: 'login',
		component: login
	},
	{
		path: '/re',
		name: 'register',
		component: register
	},
	{
		path: '/douyu',
		name: 'douyu',
		component: douyu
	},
	{
		path: '/up',
		name: 'upload',
		component: upload
	}

]

const router = createRouter({
	history: createWebHashHistory(),
	routes
})
router.beforeEach((to, from, next) => {
	if (to.path === '/login' || to.path==='/re') {
		next();
	} else {
		/* let token = localStorage.getItem('token');
		if (!token) {
			next('/login');
		} else {
			next();
		} */
next();
	}

});
export default router
